<template>
  <div class="report">
      <div class="content">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: 'Home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>数据统计</el-breadcrumb-item>
            <el-breadcrumb-item>数据报表</el-breadcrumb-item>
        </el-breadcrumb>
        <div id="myChart" :style="{width: '800px', height: '500px'}"></div>
      </div>
  </div>
</template>

<script>
  import { reports} from "../api/api.js"
  export default {
    data() {
      return {
        options: {
         }
      }
    },
    created() {
      this.reports();
    },
    methods: {
      drawLine() {
        // 基于准备好的dom，初始化echarts实例
        let myChart = this.$echarts.init(document.getElementById('myChart'))
        // 绘制图表
        myChart.setOption(this.options,true);
      },
      reports() {
        reports({
          type: 1
        }).then(res => {
          if (res.data.meta.status == 200) {
            console.log(res);
          this.options=res.data.data
           let tooltip={
            trigger: 'axis',
            axisPointer: {
              type: 'cross',
              label: {
                backgroundColor: '#6a7985'
              }
            }
          }
          let toolbox = {
            feature: {
              saveAsImage: {}
            }
          };
          this.$set(this.options,"tooltip",tooltip);
          this.$set(this.options,"toolbox",toolbox)
           this.drawLine();
          }
        })
      }
    }
  }
</script>

<style scoped lang="scss">
    .report{
        width:85%;
        height:93%;
        background-color:white;
        margin:22px auto;
        display:flex;
        justify-content: center;
        align-items:center;
        .content{
            width:97%;
            height:95%;
            display:flex;
            flex-direction: column;
        }
    }
</style>
